<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit" />
		<meta name="force-rendering" content="webkit" />
		<!-- import CSS -->
		<link rel="stylesheet" href="../js/3rd/elementUi/index.css">
		<link rel="stylesheet" href="../css/pc.css">
		<script src="../js/3rd/elementUi/vue.js"></script>
		<script src="../js/3rd/jquery-3.1.1.min.js"></script>
	</head>
	<body>
		<div id="userLists" class="user-lists" style="display:none">

			<el-container>
				<el-aside class="sider-bar" id="siderbar">
					<div class="logo"><img src="../image/logo.jpg">来赚吧管理后台</div>
					<tp-siderbar title="金种子用户"></tp-siderbar>
				</el-aside>
				<el-main>
					<div class="right-content">
						<el-breadcrumb separator-class="el-icon-arrow-right" class="bread-bd">
							<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
							<el-breadcrumb-item>金种子用户列表</el-breadcrumb-item>
						</el-breadcrumb>
						<el-row>
						  <el-col :span="24" style="display: flex;flex-direction: row;font-size: 20px;padding: 10px 0;" v-if="sumJzzData.length>0">
							  <div class="grid-content bg-purple-light" style="display: flex;flex-direction: row;align-items: center;">平台金种子总数(已挖)：<div style="font-weight: bold;font-size: 28px;color: #3580E5;">{{sumJzzData[0]}}</div></div>
							  <div class="grid-content bg-purple-light"  style="display: flex;flex-direction: row;align-items: center;margin-left: 20px;">平台金种子价值：<div style="font-weight: bold;font-size: 30px;color: #3580E5;">￥{{sumJzzData[1]}}</div></div>
							  <div class="grid-content bg-purple-light"  style="display: flex;flex-direction: row;align-items: center;margin-left: 20px;" v-if="Jzz30Price">生长剂：
								<div style="font-weight: bold;font-size: 30px;color: #3580E5;">￥{{Jzz30Price}}</div>
							  </div>
						  </el-col>
						</el-row>
						<el-form :inline="true" class="demo-form-inline" style="margin-top: 20px;">						
							<el-form-item label="用户id">
								<el-input placeholder="请输入用户id" v-model="queryUserId"></el-input>
							</el-form-item>
							<el-form-item>
								<el-button type="primary" @click="fetchList()">查询</el-button>
							</el-form-item>
				
						</el-form>					
						<template>
							<el-table :data="goldSeedUserList" stripe style="width: 100%">
								<el-table-column prop="id" label="序号" width="80">
								</el-table-column>
								<el-table-column prop="userName" label="用户名" width="180">
									<template slot-scope="scope">
									  <span >{{ scope.row.userName }}（{{scope.row.phone}}）</span>
									</template>
								</el-table-column>
								<el-table-column prop="createTime" label="时间" width="180">
									<template slot-scope="scope">
									  <span >{{ scope.row.createTime|formatData }}</span>
									</template>
								</el-table-column>
								<el-table-column label="种子码">
									<template slot-scope="scope">
									  <span>{{ getSno(scope.row.sno)  }}</span>
									  <div size="medium" style="cursor: pointer;color: #3580E5;" size="mini" @click="showEdit(scope.row.sno)">修改</div>
									  <!-- <el-button type="primary" icon="el-icon-edit" size="mini" @click="editSno()"></el-button> -->
									</template>
								</el-table-column>
								<el-table-column label="金种子数量">
									<template slot-scope="scope">
									  <span >{{ scope.row.jzzNumber }}个</span>
									</template>
								</el-table-column>
								<el-table-column label="金种子挖取数量">
									<template slot-scope="scope">
									  <span >{{ scope.row.jzzNumberDig }}个</span>
									</template>
								</el-table-column>
								<el-table-column label="金种子变现">
									<template slot-scope="scope">
									  <span >￥{{ scope.row.jzzNumberCash }}</span>
									</template>
								</el-table-column>
								<el-table-column
								  label="种子来源"
								  width="180">
								  <template slot-scope="scope">
									<el-popover trigger="click" placement="top">
										
									  <template v-for="flow in scope.row.flows">
										  <div style="margin-top:20px">
											  <p>姓名: {{ flow.user.realName }}({{flow.user.telephone}})</p>
											  <p>时间: {{ flow.createTime |formatData}}</p>
											  <p>期号: {{ flow.periodNo }}</p>
											  <p>金种子数量: {{ flow.jzzNumber }}</p>
											  <p>金种子利润: ￥{{ flow.profit }}</p>
										  </div>
									  </template>
									     
									  <div slot="reference" class="name-wrapper">
										<el-tag size="medium" style="cursor: pointer;">查看详情</el-tag>
									  </div>
									</el-popover>
								  </template>
								</el-table-column>
								<!-- <el-table-column fixed="right" label="操作">
								   <template slot-scope="scope">
									  <el-button
										size="mini"
										@click="handleCheckCrowFunding(scope.$index, scope.row)">审核</el-button>              
									</template>
								  </el-table-column> -->
							</el-table>
							<el-pagination
							  :page-size="20"
							
							  layout="prev, pager, next"
							  @current-change="handleCurrentChange"
							  :total="totalCount">
							</el-pagination>
						</template>


						<div class="clearfix"></div>
					</div>
				</el-main>

				<el-dialog title="修改sno" :visible.sync="dialogEditSnoVisible">
					<el-form>
						<el-form-item label="选择sno">
						    <el-radio-group v-model="selectedSno">
						        <el-radio :label="snoNum" name="type" v-for="snoNum in snoNumList">{{snoNum}}</el-radio>
						    </el-radio-group>
						</el-form-item>
						<el-form  :inline="true" >
							<el-form-item label="新sno">
								<el-input v-model="newSno" placeholder="请输入新sno" style="margin-left: 8px;"></el-input>
							</el-form-item>
						</el-form>
					</el-form>								
					<div slot="footer" class="dialog-footer" style="margin-top: 50px;">
						<el-button @click="dialogEditSnoVisible = false">取 消</el-button>
						<el-button type="primary" @click="editSno()">确 定</el-button>
					</div>
				</el-dialog>
			</el-container>
	</body>


	<!-- import JavaScript -->
	<script src="../js/3rd/elementUi/index.js"></script>
	<script src="../js/js/admin_siderbar.js"></script>
	<script src="../js/js/common.js"></script>
	<script>
		var token = getCookie("userToken");
		var userId = getCookie("userId");
		console.log(token)
		console.log(userId)
		if (!token || !userId) {
			window.location.href = "/admin/login.html";
		}
		new Vue({
			el: '#userLists',
			data: {
				goldSeedUserList: [],
				telephoneNum: '',
				selectRowContent: '',
				dialogExcelVisible: false,
				isDoingFetch: false,
				selectIndex: null,
				formLabelWidth: '120px',
				currentImageUrl: '',			
				value6: '',

				status:"0",
				totalCount:0,
				page:1,
				queryUserId:'',
				sumJzzData:[],
				isDoingEditSno:false,
				dialogEditSnoVisible:false,
				selectedSno:'',
				snoNumList:[],
				newSno:'',
				Jzz30Price:''
	
			},
			created: function() {
				this.fetchList()
				$("#userLists").show();
			},
			filters:{
				formatData:function(key){
				  return formatDate(key)
				}
			},
			methods: {
				getSno:function(obj){
					var dataList=Object.keys(obj);
					return dataList.join(' ')
				},
				fetchList: function() {
					if (this.isDoingFetch) {
						return
					}
					this.isDoingFetch = true;
					var getUsersUrl = "/jzz/flow/user/list";
					var data = {
						token: token,
						userId: parseInt(userId),
						client: 3,
						page: this.page,
						queryUserId:'',
						size: '20'
					}
					pushData(getUsersUrl, data, function(res) {
						console.log(res)
						this.isDoingFetch = false;
						if(res.errorCode=="008"){
						  window.location.href = "/admin/login.html";
						}
						if (res.state) {
							this.goldSeedUserList = res.data.jzzUser;
							this.sumJzzData=res.data.JzzSum;
							this.Jzz30Price=res.data.Jzz30Price;
							this.totalCount=res.data.totalCount
						} else {
							this.$message.warning(res.message+'原因:'+res.data.result)
						}
					}.bind(this));
				},
				
				/*分页*/
				handleCurrentChange:function(val){
				     this.page=val;
					 this.fetchList()
				},
				editSno:function(){
					if(this.isDoingEditSno){
						return
					}
					var url='/jzz/flow/modify/sno';
					var data={						  
						  newSno: this.newSno,
						  oldSno: this.selectedSno,
						  token: token,
						  userId: parseInt(userId),
						  client: 3,
						}
					pushData(url,data,function(res){
						if(res.errorCode=="008"){
						  window.location.href = "/admin/login.html";
						}
						if (res.state) {
							this.dialogEditSnoVisible=false;
							this.$message({
							  message: '修改成功',
							  type: 'success'
							});
							this.fetchList()
						} else {
							this.$message.warning(res.message+'原因:'+res.data.result)
						}
					}.bind(this))
				},
				showEdit:function(rowData){
					this.dialogEditSnoVisible=true;
					console.log(this.dialogEditSnoVisible)
					this.snoNumList=Object.keys(rowData)
				},
				getGrowPrice:function(goldSeedNum,goldSeedPrice){
					var onePrice=parseFloat(goldSeedPrice)/parseFloat(goldSeedNum)
					//生长剂计算（平台种子价值  除以平台种子数量），乘以10万枚得到总市值 总市值减去1000万就是生长剂总额

					var glowPrice=onePrice*100000-10000000;
					return glowPrice
				}

			}


		})
	</script>
</html>
